package com.elm_springboot_s.service.impl;

import com.elm_springboot_s.mapper.CartMapper;
import com.elm_springboot_s.pojo.Cart;
import com.elm_springboot_s.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CartServiceImpl implements CartService {

    @Autowired
    private CartMapper cartMapper;

    @Override
    public List<Cart> listCartByUserId(Long userId) {
        return cartMapper.listCartByUserId(userId);
    }

    @Override
    public List<Cart> listCartByUserIdAndBusinessId(Long userId, Integer businessId) {
        return cartMapper.listCartByUserIdAndBusinessId(userId, businessId);
    }

    @Override
    public int saveCart(Long userId, Integer businessId, Integer foodId) {
        return cartMapper.saveCart(userId, businessId, foodId);
    }

    @Override
    public int updateCart(Long userId, Integer businessId, Integer foodId, Integer quantity) {
        return cartMapper.updateCart(userId, businessId, foodId, quantity);
    }

    @Override
    public int removeCart(Long userId, Integer businessId, Integer foodId) {
        return cartMapper.removeCartByUserIdAndBusinessIdAndFoodId(userId, businessId, foodId);
    }

    @Override
    public int removeCartByUserIdAndBusinessId(Long userId, Integer businessId) {
        return cartMapper.removeCartByUserIdAndBusinessId(userId, businessId);
    }
} 